package com.ymt.consumer.service.impl;

import com.ymt.consumer.dao.FinancialReceiptsMapper;
import com.ymt.consumer.domain.FinancialReceipts;
import com.ymt.consumer.service.FinancialReceiptsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "financialReceiptsService")
public class FinancialReceiptsServiceImpl implements FinancialReceiptsService {
    private static final Logger LOGGER = LoggerFactory.getLogger(FinancialReceiptsServiceImpl.class);

    @Autowired
    private FinancialReceiptsMapper financialReceiptsMapper;

    @Override
    public void recordReceipt(FinancialReceipts financialReceipts) {
        financialReceiptsMapper.insert(financialReceipts);
        LOGGER.info(">>> 【业务消费端】添加财务收款记录成功!订单编号:{},收款金额:{},收款来源:{}",
                financialReceipts.getOrderCode(), financialReceipts.getReceipt(), financialReceipts.getSource());
    }

    @Override
    public boolean alreadyReceipt(String orderCode) {
        Long count = financialReceiptsMapper.countByOrderCode(orderCode);
        return count > 0 ? true : false;
    }
}
